package com.nf.ch03.test06.three;

import java.util.Random;

/**
 * 小偷
 *
 * @author lwj
 * @date 2025-03-04
 * @vesion 1.0.0
 */
public class Thief extends Person {
    // 构造方法
    public Thief() {}
    public Thief(String name) {
        super(name);
    }

    /**
     * 开门
     * @param door 门
     */
    @Override
    public void openDoor(Door door){
        // 判断当前传入进去的门是否是防盗门
        if(door instanceof SecurityDoor){
            // 是，触发防盗警报
            ((SecurityDoor) door).ring();
        }else{
            if(new Random().nextInt(10) < 5){
                System.out.println("偷盗失败");
            }else{
                door.open();
            }
        }
    }
}
